package edu.tongji.structureplayer.control
{
    import edu.tongji.structureplayer.core.SolverI;
    import edu.tongji.structureplayer.file.StructureFileManagerI;
    import edu.tongji.structureplayer.file.XMLManagerI;
    import edu.tongji.structureplayer.structure.WellBehavedStructure;
    
    import flash.filesystem.File;
    
    import org.as3commons.collections.framework.IMap;
    
    public class Controller implements ControllerI
    {
        private var _xmlManager:XMLManagerI;
        private var _structureFileManager:StructureFileManagerI;
        private var _solver:SolverI;
        
        public function exportXML(structure:WellBehavedStructure, file:File):void
        {
            _xmlManager.exportXML(structure, file);
        }
        
        public function importXML(file:File):WellBehavedStructure
        {
            return _xmlManager.importXML(file);
        }
        
        public function save(structure:String, file:File):void
        {
            _structureFileManager.save(structure, file);
        }
        
        public function open(file:File):String
        {
            return _structureFileManager.open(file);
        }
        
        public function solve(structure:WellBehavedStructure):void
        {
            _solver.solve(structure);
        }
        
        public function getDelta():IMap
        {
            return _solver.getDelta();
        }
        public function getForce():IMap
        {
            return _solver.getForce();
        }

        public function get xmlManager():XMLManagerI
        {
            return _xmlManager;
        }

        public function set xmlManager(value:XMLManagerI):void
        {
            _xmlManager = value;
        }

        public function get structureFileManager():StructureFileManagerI
        {
            return _structureFileManager;
        }

        public function set structureFileManager(value:StructureFileManagerI):void
        {
            _structureFileManager = value;
        }

        public function get solver():SolverI
        {
            return _solver;
        }

        public function set solver(value:SolverI):void
        {
            _solver = value;
        }


    }
}